/**
 * 组织架构的 API 模块
 */

import request from '@/utils/request'

export function getDepartments() {
  return request({
    url: '/company/department',
    method: 'get'
  })
}

/**
 * @description: 获取负责人列表
 * @returns
 */

export function getEmployeeSimple() {
  return request({
    url: '/sys/user/simple',
    method: 'get'
  })
}

/**
 * @description: 添加部门
 * @param {*} data
 * @returns
 */

export function addDepartments(data) {
  return request({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * @description: 根据 id 查询部门的详情
 * @param {*} id  部门的id
 * @returns
 */

export function getDepartDetail(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'get'
  })
}

/**
 * @description: 更新部门数据 / 编辑部门数据
 * @param {*} data
 * @returns
 */

export function updateDepartments(data) {
  return request({
    url: `/company/department/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * @description:  根据 id 删除部门
 * @param {*} id
 * @returns
 */

export function delDepartment(id) {
  return request({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}
